package com.budwk.app.sqfwV2.generator.centuryCitySecurity.excel;

import cn.hutool.core.date.DateUtil;
import com.budwk.app.sqfw.enums.DownLoadFileNameEnum;
import com.budwk.app.sqfw.models.Sqfw_formSummary_new;
import com.budwk.app.sqfwDoc.bo.SqfwExcelForSummaryBO;
import com.budwk.app.sqfwDoc.bo.SqfwExcelJudgeRes;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseTemplateExcelGenerator;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.SqfwExcelCreateCommonBO;
import com.budwk.app.sqfwV2.component.DayingRoadPdfComponent;
import com.budwk.app.sqfwV2.component.centuryCity.CommCenturyCityDataHandleUtil;
import com.budwk.app.sqfwV2.dto.image.CenturyCityExcelImageConfigBO;
import com.budwk.app.sqfwV2.enums.CenturyCitySafeServiceEnum;
import com.budwk.app.util.poiUtils.excelPictureConfigBO.ExcelFileCreateParamBO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 东方祥云低代码1.1
 * @since 2024-02-18
 * <p>
 * 世纪城安全巡查表 safe_check_task
 * 重点场所问题隐患清单.xlsx
 */
@Slf4j
public class KeysLocationsHiddenDangersGenerator extends BaseTemplateExcelGenerator {

    @Override
    protected void customerPopularSheetBaseParam(Map<String, Object> excelParam, SqfwExcelCreateCommonBO excelCreateParam) {
        CommCenturyCityDataHandleUtil.buildUnitName(excelParam, excelCreateParam);
    }

    @Override
    protected void customerPopularSheetDataParam(List<Map<String, Object>> listMap, SqfwExcelCreateCommonBO excelCreateParam) {

    }

    @Override
    protected String getTemplateName() {
        return CenturyCitySafeServiceEnum.CENTER_CITY_KEY_LOCATION.getTemplatePath();
    }

    @Override
    public String getDownloadFileName() {
        String fileName = DayingRoadPdfComponent.getDictName(CenturyCitySafeServiceEnum.CENTER_CITY_KEY_LOCATION.getCode(), null);
        if (StringUtils.isBlank(fileName)) {
            fileName = DownLoadFileNameEnum.CENTER_CITY_KEY_LOCATION.getName();
        } else {
            fileName = fileName.split("\\.")[0];
        }
        return fileName + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss");
        //return DownLoadFileNameEnum.CENTER_CITY_KEY_LOCATION.getName();
    }

    @Override
    protected void completeExcelFileCreateParam(ExcelFileCreateParamBO excelFileCreateParam) {

    }

    @Override
    protected void customerPopularRowDataMap(Map<String, Object> rowDataMap, SqfwExcelForSummaryBO forSummaryBO) {
        CommCenturyCityDataHandleUtil.rowDataBuild(rowDataMap, forSummaryBO);
    }

    @Override
    protected SqfwExcelJudgeRes judgeDataIntoExcelBeforeErgodic(SqfwExcelCreateCommonBO excelCreateParam, Map<String, Object> excelParam) {
        return null;
    }

    @Override
    protected SqfwExcelJudgeRes judgeDataIntoExcelBeforeCreate(Map<String, Object> excelParam) {
        return null;
    }

    @Override
    protected Class<?> getImageConfigBO() {
        return CenturyCityExcelImageConfigBO.class;
    }

    public boolean isGenerateExcel(List<Sqfw_formSummary_new> dataList) {
        return CommCenturyCityDataHandleUtil.checkData(dataList);
    }

}
